package net.yambal.android.infomation.weather.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class DBHelperWeather extends SQLiteOpenHelper {
	private static final String DB_NAME = "weather.db";
	private static final int DB_VERSION = 1;
	private static DBHelperWeather _my_instance = null;
	
	public DBHelperWeather(Context context) {
		super( context.getApplicationContext(), DB_NAME, null, DB_VERSION );
	}
	
	synchronized static
	public DBHelperWeather getInstance( Context context ){
		if ( _my_instance == null ){
			_my_instance = new DBHelperWeather(context);
		}
		return _my_instance;
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		CreateMyLocationTable(db);
	}

	@Override
	public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
		// TODO Auto-generated method stub

	}
	
	private void CreateMyLocationTable(SQLiteDatabase db){
		db.execSQL("CREATE TABLE IF NOT EXISTS " + TableWeather.TABLE + " (" +
				"_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL," +
				"mills INTEGER NOT NULL," +
				"location_label TEXT NOT NULL," +
				"txt TEXT NOT NULL," +
				"highest_temperature INTEGER," +
				"minimum_temperature INTEGER," +
				"source TEXT DEFAULT NULL" +
				")");
	}
	

}
